use super::queue::Queue;

pub struct IntoIter<T>(Queue<T>);

impl<T> IntoIter<T> {
    pub fn new(queue: Queue<T>) -> IntoIter<T> {
        IntoIter(queue)
    }
}

impl<T: Clone> Iterator for IntoIter<T> {
    type Item = T;

    fn next(&mut self) -> Option<Self::Item> {
        if !self.0.is_empty() {
            Some(self.0.data.remove(0))
        } else {
            None
        }
    }
}
